package com.microservice.salmon.db.enums;

import lombok.Getter;

/**
 * <p>
 *  订单状态	-3:用户拒收 -2:用户取消 -1:未付款 0:已付款 1: 待发货 2: 已发货 3: 配送中 4: 交易成功
 * </p>
 *
 * @author 王洪庆 2019-03-07 10:38
 */
@Getter
public enum OrderStatusEnum {

    USER_REFUSE("-3", "用户拒收"),
    CANCELED("-2", "用户取消"),
    NO_PAY("-1","未支付"),
    UP_PAY("0","已支付"),
    GOODS_WAIT_SHIPPING("1", "待发货"),
    GOODS_SHIPPED("2", "已发货"),
    GOODS_IN_SHIPPING("3", "配送中"),
    USER_CONFIRM_RECEIVED("4", "交易成功");

    private Byte code;
    private String message;
    OrderStatusEnum(String code, String message) {
        this.code = Byte.valueOf(code);
        this.message = message;
    }

    public static OrderStatusEnum codeOf(Byte code){
        for(OrderStatusEnum orderStatusEnum : values()){
            if(orderStatusEnum.getCode().equals(code)){
                return orderStatusEnum;
            }
        }
        throw new RuntimeException("没有找到对应的枚举");
    }

}
